package com.kevin.test.spring.ioc;

import java.beans.PropertyEditorSupport;

import org.apache.commons.lang3.StringUtils;

import com.kevin.utility.common.DateUtils;

public class DatePropertyEditor extends PropertyEditorSupport {
	private String format = "yyyy-MM-dd";

	public void setFormat(String format) {
		this.format = format;
	}
	
	public void setAsText(String text){
		if(StringUtils.isEmpty(format)){
			format = DateUtils.SIMPLE_DEFAULT_FORMAT;
		}
		DateUtils.toDate(text, format);
	}
}
